// Fill out your copyright notice in the Description page of Project Settings.


#include "MyStyle.h"
#include "Styling/SlateStyleRegistry.h"
#include "Slate/SlateGameResources.h"
#include "MySlateWidgetStyle.h"

const  struct FMySlateStyle* MyStyle::UIStyle;
TSharedPtr<FSlateStyleSet> MyStyle::StyleInstance = nullptr;
void MyStyle::Initialize()
{
	if (!StyleInstance.IsValid())
	{
		StyleInstance = Create();
		FSlateStyleRegistry::RegisterSlateStyle(*StyleInstance);

		UIStyle = &MyStyle::Get().GetWidgetStyle<FMySlateStyle>("MainUIStyle_BP");
	}
}

FName MyStyle::GetStyleSetName()
{
	static FName SlateSetName(TEXT("GanttUIStyleManager"));
	return SlateSetName;
}

void MyStyle::ShutDown()
{
	FSlateStyleRegistry::UnRegisterSlateStyle(*StyleInstance);
	ensure(StyleInstance.IsUnique());
	StyleInstance.Reset();
}

const ISlateStyle& MyStyle::Get()
{
	return *StyleInstance;
}

TSharedRef<FSlateStyleSet> MyStyle::Create()
{
	TSharedRef<FSlateStyleSet> StyleRef = FSlateGameResources::New(MyStyle::GetStyleSetName(),
		"/Game/UI/style", "/Game/UI/style");
	return StyleRef;
}
